/**
 * creation: 9-mrt-2006
 */
package org.jfonia.staffnotation;

import java.util.HashMap;
import java.util.Map;



/**
 * @author Wijnand
 * 
 * class used to keep track of local modifiers (accidentals) in a score
 * 1. local modifiers   per rank 
 * 2. global modifiers  per reduced rank -> depend on key signature
 */
public class KeySignatureContext
{

	/**
	 * @param signatureType 0: no accidentals, 1: f-sharp, -1:b-flat etc.. 
	 */
	public KeySignatureContext(BasicKeySignature keySig)
	{
		this.keySig = keySig;
		localMods = new HashMap<Integer, Integer>();
	}
	
	public void clearLocal()
	{
		localMods.clear();
	}
	
	public int getModifier(int rank)
	{
		if (localMods.containsKey(rank))
			return localMods.get(rank);
		else
			return keySig.getModifier((rank+7000)%7);
	}
	
	/**
	 * use in case of non-null (visual) accidental
	 * @param rank
	 * @param mod
	 */
	public void setLocal(int rank, int mod)
	{
		localMods.put(rank, mod);
	}
	
	protected BasicKeySignature     keySig;
	protected Map<Integer, Integer> localMods;	// local accidentals (per bar)
}
